<%@page import="bean.VisitDTO"%>
<%@page import="bean.VisitVo"%> 
<%@page import="java.util.ArrayList"%>

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>방명록</title>
<link rel='styleSheet' href="../css/VisitMain.css"/>
<script src='../js/VisitMain.js'></script>
</head>
<body>
<jsp:useBean id="vo" class="bean.VisitVo" scope="page"/>
<jsp:setProperty property="*" name="vo"/>    <!-- vo와 넘어온name의 변수명이같아야지만 setter에 넘겨준다.-->
<%
String mid="";
if(session.getAttribute("sessionMid")!=null){
	mid = (String)session.getAttribute("sessionMid");
}
 


VisitDTO dto=new VisitDTO();
dto.setVo(vo);
boolean b=true;

if(request.getParameter("t")!=null){
	if(request.getParameter("t").equals("1")){
		b	 = dto.visitWrite(mid); 
		%>	
		<script type="text/javascript">location.href = "guest_main.jsp?inPage=../guest/visitMain.jsp";</script> <%
	}
}


ArrayList<VisitVo> al = dto.select();

%>
<div class='visitTitle'>
	<a> > 방명록</a>
</div>
	<form name='frm' method='post' action='guest_main.jsp?inPage=../guest/visitMain.jsp'>
	<!-- 	<div id="top">
		</div> -->
		<div id="writeBox">
			<textarea id ='writeTextarea' name='content' ></textarea>
			<div id="writeBtnDiv">
				<a>방명록을 남겨주세요♥ 3: )</a>
				<input type='button' value='글쓰기' id='writeBtn' onclick='input();' /><br/>
			</div>
		</div>



<%if(b){
%>
		<br/><br/><br/>
<%for(int i=0; i<al.size(); i++){
	VisitVo v = al.get(i);	
 %> 
		
			<div class="viewBox">
			<div class="viewBox_bar"> <!-- 글쓴이, 날짜 나오는곳 -->
				<label class=viewBox_bar_mid>아이디 : <%=v.getMid() %></label> <!-- 글쓴이 -->
				<label class=viewBox_bar_wdate>( <%=v.getVdate() %> )</label> <!-- 게시 날짜 -->
			</div>
			<%
			int s=0;	
			if( request.getParameter("moveModify")!=null){
				s = Integer.parseInt(request.getParameter("moveModify"));
			}
			if(s==v.getVno()){
				%>
				<textarea class = 'modifyContent2' id='modifyContent2' ><%=v.getContent() %></textarea>
					<div class = "modiDeleBtn">
						<input type='button' value='확인' onclick='modiChoice(<%=v.getVno()%>);'/>
					</div>
			<%} else {%>
			<textarea class = 'modifyContent' name='modifyContent' disabled="disabled" style='font-family: "tc";font-size: 20px; '><%=v.getContent()%>	</textarea>
				<div class = "modiDeleBtn">
				<%
				if(mid.equals(v.getMid())){
				%>
		
					<input type='button' value='수정' class='visit_modi_btn'onclick='modiOpen(<%= v.getVno()%>, <%=vo.getNowPage() %>);' />
					<input type='button' value='삭제' class='visit_dele_btn' onclick='deleteChoice(<%=v.getVno() %>,<%=vo.getNowPage() %>);' />
		
				<%} %><br/>
			</div>
			<%  }	%>
				<br/>

			</div>
		


		<br/><br/><br/><br/>
		<%} } %>
	</form>
	<form name="visit_list_frm" method="post" action="../jsp/guest_main.jsp?inpage=../guest/visitMain.jsp">
	<input type='text' name='find' class = 'visit_search_box' value = '<%=vo.getFind()%>'>
	<input type='submit' class = 'visit_search_btn' value= '검색'>
</form>
	<form name='hiddenFrm' method='post'>
		<input type='hidden' name='content' />
		<input type='hidden' name='vno'/>
	</form>
	<form name='hiddenFrm2' method='post'>
		<input type='hidden' name='vno'>
		<input type='hidden' name='nowPage'>
		<input type='hidden' name='find'>
	</form>
	<form name='hiddenreple' method='post'>
		<input type='hidden' name='rcontent'/>
		<input type='hidden' name='vno'/>
	</form>

		<div id = 'list_page'>
	<%if(dto.getNowBlock()>=1) {%>
	<a href='#' onclick='goPage(1)'>맨첨</a>
	<%} %>
	<a href='#' onclick='goPage(<%=dto.getNowPage()-1 %>)'>◀</a>
	
	<% 
	int i=0;
	for( i=dto.getStartPage(); i<=dto.getEndPage(); i++){%>
			<a href='#' onclick = 'goPage( <%=i%> )'><%=i %></a>
	 <%}%>

	 <a href='#' onclick='nextPage(<%=dto.getNowPage()%>, <%=dto.getEndPage() %>)' >▶</a>

	  <a href='#' onclick=' goPage(<%=dto.getTotPage()%>)'>맨끝</a>
	</div>
	<input type='hidden' id = 'loginId' value='<%=mid %>' >
<script>Init();</script>



</body>
</html>

